//
//  LPActivityDetailReportDetailTableViewCell.m
//  LovingPartyBuilding
//
//  Created by 刘应平 on 2017/6/6.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "LPActivityDetailReportDetailTableViewCell.h"

@interface LPActivityDetailReportDetailTableViewCell ()
/**  ten  */
@property (strong, nonatomic) TenGrayShadowView  *five;
/**  iamgeVEIW  */
@property (strong, nonatomic) UIImageView  *lpImageView;
/**  label  */
@property (strong, nonatomic) UILabel  *lpContentLabel;
/**  时间  */
@property (strong, nonatomic) UILabel  *lpTimeLabel;

@end
@implementation LPActivityDetailReportDetailTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
/**  130  */
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
       [self layoutUI];
    }
    return self;
}




#pragma mark - 界面
- (void)layoutUI{
    [self addSubview:self.five];
    [self addSubview:self.lpImageView];
    [self addSubview:self.lpTimeLabel];
    [self addSubview:self.lpContentLabel];
    
    self.five.sd_layout
    .bottomEqualToView(self)
    .leftEqualToView(self)
    .rightEqualToView(self)
    .heightIs(10 * [UIScreen zj_screenHScale]);
    
    self.lpImageView.sd_layout
    .topSpaceToView(self, 10 * [UIScreen zj_screenHScale])
    .leftSpaceToView(self, 10 * [UIScreen zj_screenWScale])
    .widthIs(100 * [UIScreen zj_screenWScale])
    .heightIs(100 * [UIScreen zj_screenHScale]);
    
    self.lpContentLabel.sd_layout.topSpaceToView(self, 13 * [UIScreen zj_screenHScale])
    .leftSpaceToView(self.lpImageView, 10 * [UIScreen zj_screenWScale])
    .widthIs([UIScreen zj_screenWith] - 130 * [UIScreen zj_screenWScale])
    .heightIs(77 * [UIScreen zj_screenHScale]);
    
    self.lpTimeLabel.sd_layout.bottomEqualToView(self.lpImageView)
    .leftSpaceToView(self.lpImageView, 10 * [UIScreen zj_screenWScale])
    .widthIs([UIScreen zj_screenWith] - 130 * [UIScreen zj_screenWScale])
    .heightIs(13 * [UIScreen zj_screenHScale]);
}

- (void)setModel:(LPActivityDetailReportDetailmodel *)model{
    _model = model;

    
    [self.lpImageView sd_setImageWithURL:CREATEURL(model.COVERURL) placeholderImage:PlaceholderImage];
    self.lpTimeLabel.text = model.CREATETIME;
    
    
    if (model.HEIGHT < 77 * [UIScreen zj_screenHScale]) {
        self.lpContentLabel.sd_layout.heightIs(model.HEIGHT);
        [self.lpContentLabel updateLayout];
    }
    
    self.lpContentLabel.attributedText = [UILabel setSpaceForLineWithText:model.TITLE lineSpace:3 * [UIScreen zj_screenHScale]];
    
}


- (void)setIsLastCell:(BOOL)isLastCell{
    _isLastCell = isLastCell;
    self.five.hidden = YES;
}
#pragma mark - getter
- (TenGrayShadowView *)five{
    if (_five == nil) {
        _five = [TenGrayShadowView new];
        _five.backgroundColor = [UIColor themeGrayColor];
    }
    return _five;
}
- (UILabel *)lpContentLabel{
    if (!_lpContentLabel) {
        _lpContentLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.numberOfLines = 0;
            label.textColor = [UIColor textBlackColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:16 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _lpContentLabel;
}


- (UILabel *)lpTimeLabel{
    if (!_lpTimeLabel) {
        _lpTimeLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor lightGrayColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:15 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _lpTimeLabel;
}

- (UIImageView *)lpImageView{
    if (!_lpImageView) {
        _lpImageView = [UIImageView new];
        _lpImageView.contentMode = UIViewContentModeScaleToFill;
    }
    return _lpImageView;
}
@end
